package com.eliza.demo.vm

import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import com.eliza.library.dao.ContactorRepository
import com.eliza.library.model.Contactor


/*-*- coding:utf-8 -*-
 * @Author  : debi
 * @Time    : 5/1/22
 * @Software: Android Studio
 */

/*
* 保存数据库信息
* */
class ContactorDbVm : AndroidViewModel {
    private var repository: ContactorRepository

    constructor(application: Application) : super(application) {
        this.repository = ContactorRepository(application);
    }

    suspend fun insertCon(vararg contactor: Contactor) {
        repository.insertCon(*contactor)
    }

    suspend fun deleteCon(vararg contactor: Contactor) {
        repository.deleteCon(*contactor)
    }


    suspend fun updateCon(vararg contactor: Contactor) {
        repository.updateCon(*contactor)
    }

    fun getAllContactorsLive(): LiveData<List<Contactor>> {
        return repository.getAllConList
    }
}